|
|
|
|
|
|
|
To better understand how objects communicate, here's an example from the bank teller system under development. After elaborating the design of the application with your client at the Second Bank of Carrollton, you discovered the need for a Deposit class that acts as a controller and a BasicPersonalCheckingAccount class as a bank product class. These two objects, along with some prototypical lines of code, are represented in Listing 4.1. |
|
|
|
|
|
|
|
|
LISTING 4.1. EXAMPLE OF INTEROBJECT COMMUNICATION IN THE SAMSONA BANK TELLER SYSTEM EXAMPLE. |
|
|
|
 |
|
|
|
|
1: Object: theDeposit
2:
3: Methods:
4: Public Function depositFunds(argAccountNumber As String,
argAmount As Single)
5: 'We'll use Call for the sake of simplicity.
6: Call theBasicPersonalCheckingAccount.adjustBalance(Me,
argAccountNumber)
7: End Function
8:
9: Sub Class_Initialize()
10: msgl_Amount = 250.00
11: ms_AccountNumber = 1002345
12: End Sub
13:
14: Properties:
15: Amount
16:
17:
18: Object: theBasicPersonalCheckingAccount
19:
20: Methods:
21: Public Function adjustBalance(ByRef argObject, argAccountNumber As String)
22: Dim LocalObject As Object
23:
24: 'If there's more than one account object in memory, a precondition
25: 'is that this object is the correct object. So check account number
26: If argAccountNumber <> AccountNumber Then
27: 'Raise exceptions here
28:
29: Exit Function
30: End If
31:
|
|
|
|
|
|